import { ref, computed } from "vue";
import { defineStore } from "pinia";

export const useStore = defineStore("users", {
  state: () => ({
    Val: "",
    fiage: false,
    Ids: 0,
    id: 0,
    Aid: 0,
    List: [],
    Active: [],
    Comple: [],
    arr: ["All", "Active", "Completed", "Clear completed"],
  }),
  getters: {
    Len(state) {
      return state.List.filter((item) => item.flag === false).length;
    },
    Lens(state) {
      return state.List.filter((item) => item.flag === true).length;
    },
  },
  actions: {
    Change() {
      this.flags = false;
      this.List[this.Ids].flag = !this.List[this.Ids].flags;
      console.log(this.Ids);
      if (this.Lens <= 0) {
        this.flags = true;
      }
    },
    Del() {
      this.List.splice(this.id, 1);
    },
    Jump() {
      if (this.Aid === 1) {
        this.Active = this.List.filter((item) => item.flag === flase);
        console.log(this.Active);
      } else if (this.Aid === 2) {
        this.Comple = this.List.filter((item) => item.flag === true);
      } else if (this.Aid === 3) {
        this.List = this.List.filter((item) => item.flag === false);
        this.Aid = 0;
        this.flags = true;
      }
    },
  },
});
